package com.wang.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @description:
 * @author：tuimao
 * @date: 2024/11/11
 */
public class DateUtil {
    private final static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    private static String formatDateTime(LocalDateTime dateTime) {
        return dateTime.format(formatter);
    }

    private static LocalDateTime parseDateTime(String dateTimeStr) {
        return LocalDateTime.parse(dateTimeStr, formatter);
    }

    public static String getNowDate(){
        LocalDateTime now = LocalDateTime.now();
        String formatted = formatDateTime(now);
        LocalDateTime parsed = parseDateTime(formatted);
        return formatted;
    }
}
